# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from $uifile import $uiclass

class ${winclass}(QMainWindow):
    def __init__(self, parent=None):
        super(${winclass}, self).__init__(parent)
        self.ui = ${uiclass}()
        self.ui.setupUi(self)
#if $keepstate
        self.read_settings()

    def closeEvent(self, event):
        self.write_settings()
        event.accept()
#end if

#if $usesettings
    def read_settings(self):
        settings = QSettings()
        self.restoreGeometry(settings.value("geometry").toByteArray())
        self.restoreState(settings.value("state").toByteArray())
    
    def write_settings(self):
        settings = QSettings()
        settings.setValue("geometry", self.saveGeometry())
        settings.setValue("state", self.saveState())
#end if